package com.iw.sms.service;

import org.springframework.stereotype.Component;

import com.alvin.sms.model.SendSmsVO;
import com.alvin.sms.service.SmsService;
import com.iw.sms.quartz.SmsConfig;

@Component
public class AlvinSmsService extends SmsService{

	public static boolean isRun = false;
	
	static {
		isRun = SmsConfig.getRun(SmsConfig.AUTO_SMS_RUN);
	}

	public AlvinSmsService() {
		super();
	}


	@Override
	public boolean sendSms(SendSmsVO sms) {
		if (isRun) {
			return super.sendSms(sms);
		} else {
			sms.setStime(null);
			return false;
		}
	}

	public void stopSend() {
		isRun = false;
		SmsConfig.setProperty(SmsConfig.AUTO_SMS_RUN, false);
	}

	public void startSend() {
		SmsConfig.setProperty(SmsConfig.AUTO_SMS_RUN, true);
		isRun = true;
	}

}
